/*
 * Copyright (C) 2008-12  Bernhard Hobiger
 *
 * This file is part of HoDoKu.
 *
 * HoDoKu is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * HoDoKu is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with HoDoKu. If not, see <http://www.gnu.org/licenses/>.
 */
package sudoku;

import generator.BackgroundGeneratorThread;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JColorChooser;
import javax.swing.JLabel;
import javax.swing.UIManager;

/**
 *
 * @author  hobiwan
 */
public class ConfigLevelFontPanel extends javax.swing.JPanel {
    private static final long serialVersionUID = 1L;

    private JButton[] levelFGButtons;
    private JButton[] levelBGButtons;
    //private JLabel[] levelLabels;
    private DifficultyLevel[] levels;
    private Font[] fonts;
    private JLabel[] fontLabels;
    private double valueFactor;
    private double candidateFactor;
    private double hintFactor;
    private double boxFactor;

    /**
     * Creates new form ConfigGeneralPanel
     * @param mainFrame 
     */
    public ConfigLevelFontPanel(Component mainFrame) {
        initComponents();

        levelFGButtons = new JButton[Options.getInstance().getDifficultyLevels().length];
        levelFGButtons[0] = incompleteFGButton;
        levelFGButtons[1] = easyFGButton;
        levelFGButtons[2] = mediumFGButton;
        levelFGButtons[3] = hardFGButton;
        levelFGButtons[4] = unfairFGButton;
        levelFGButtons[5] = extremeFGButton;
        levelBGButtons = new JButton[Options.getInstance().getDifficultyLevels().length];
        levelBGButtons[0] = incompleteBGButton;
        levelBGButtons[1] = easyBGButton;
        levelBGButtons[2] = mediumBGButton;
        levelBGButtons[3] = hardBGButton;
        levelBGButtons[4] = unfairBGButton;
        levelBGButtons[5] = extremeBGButton;

        fonts = new Font[4];
        fontLabels = new JLabel[4];
        fontLabels[0] = valuesFontLabel;
        fontLabels[1] = candidatesFontLabel;
        fontLabels[2] = printLargeFontLabel;
        fontLabels[3] = printSmallFontLabel;

        easyTextField.setDocument(new NumbersOnlyDocument());
        mediumTextField.setDocument(new NumbersOnlyDocument());
        hardTextField.setDocument(new NumbersOnlyDocument());
        unfairTextField.setDocument(new NumbersOnlyDocument());
        extremeTextField.setDocument(new NumbersOnlyDocument());
        
        initAll(false);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        easyLabel = new javax.swing.JLabel();
        mediumLabel = new javax.swing.JLabel();
        hardLabel = new javax.swing.JLabel();
        unfairLabel = new javax.swing.JLabel();
        extremeLabel = new javax.swing.JLabel();
        easyTextField = new javax.swing.JTextField();
        mediumTextField = new javax.swing.JTextField();
        hardTextField = new javax.swing.JTextField();
        unfairTextField = new javax.swing.JTextField();
        extremeTextField = new javax.swing.JTextField();
        easyFGButton = new javax.swing.JButton();
        mediumFGButton = new javax.swing.JButton();
        hardFGButton = new javax.swing.JButton();
        unfairFGButton = new javax.swing.JButton();
        extremeFGButton = new javax.swing.JButton();
        easyBGButton = new javax.swing.JButton();
        mediumBGButton = new javax.swing.JButton();
        hardBGButton = new javax.swing.JButton();
        unfairBGButton = new javax.swing.JButton();
        extremeBGButton = new javax.swing.JButton();
        incompleteLabel = new javax.swing.JLabel();
        incompleteFGButton = new javax.swing.JButton();
        jTextField1 = new javax.swing.JTextField();
        incompleteBGButton = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        valuesLabel = new javax.swing.JLabel();
        candidatesLabel = new javax.swing.JLabel();
        printLargeLabel = new javax.swing.JLabel();
        printSmallLabel = new javax.swing.JLabel();
        valuesFontLabel = new javax.swing.JLabel();
        candidatesFontLabel = new javax.swing.JLabel();
        printLargeFontLabel = new javax.swing.JLabel();
        printSmallFontLabel = new javax.swing.JLabel();
        valuesButton = new javax.swing.JButton();
        candidatesButton = new javax.swing.JButton();
        printLargeButton = new javax.swing.JButton();
        printSmallButton = new javax.swing.JButton();
        valueFactorLabel = new javax.swing.JLabel();
        candidatesFactorLabel = new javax.swing.JLabel();
        hintFactorLabel = new javax.swing.JLabel();
        valueFactorTextField = new javax.swing.JTextField();
        candidateFactorTextField = new javax.swing.JTextField();
        hintFactorTextField = new javax.swing.JTextField();
        boxFactorLabel = new javax.swing.JLabel();
        boxFactorTextField = new javax.swing.JTextField();
        resetButton = new javax.swing.JButton();

        java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("intl/ConfigLevelFontPanel"); // NOI18N
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("ConfigLevelFontPanel.jPanel1.border.title_1"))); // NOI18N

        easyLabel.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("intl/ConfigLevelFontPanel").getString("ConfigLevelFontPanel.easyLabel.mnemonic").charAt(0));
        easyLabel.setLabelFor(easyTextField);
        easyLabel.setText(bundle.getString("ConfigLevelFontPanel.easyLabel.text_1")); // NOI18N

        mediumLabel.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("intl/ConfigLevelFontPanel").getString("ConfigLevelFontPanel.mediumLabel.mnemonic").charAt(0));
        mediumLabel.setLabelFor(mediumTextField);
        mediumLabel.setText(bundle.getString("ConfigLevelFontPanel.mediumLabel.text_1")); // NOI18N

        hardLabel.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("intl/ConfigLevelFontPanel").getString("ConfigLevelFontPanel.hardLabel.mnemonic").charAt(0));
        hardLabel.setLabelFor(hardTextField);
        hardLabel.setText(bundle.getString("ConfigLevelFontPanel.hardLabel.text_1")); // NOI18N

        unfairLabel.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("intl/ConfigLevelFontPanel").getString("ConfigLevelFontPanel.unfairLabel.mnemonic").charAt(0));
        unfairLabel.setLabelFor(unfairTextField);
        unfairLabel.setText(bundle.getString("ConfigLevelFontPanel.unfairLabel.text_1")); // NOI18N

        extremeLabel.setLabelFor(extremeTextField);
        extremeLabel.setText(bundle.getString("ConfigLevelFontPanel.extremeLabel.text_1")); // NOI18N

        extremeTextField.setEditable(false);

        easyFGButton.setMaximumSize(new java.awt.Dimension(60, 20));
        easyFGButton.setMinimumSize(new java.awt.Dimension(60, 20));
        easyFGButton.setPreferredSize(new java.awt.Dimension(60, 20));
        easyFGButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                easyFGButtonActionPerformed(evt);
            }
        });

        mediumFGButton.setMaximumSize(new java.awt.Dimension(60, 20));
        mediumFGButton.setMinimumSize(new java.awt.Dimension(60, 20));
        mediumFGButton.setPreferredSize(new java.awt.Dimension(60, 20));
        mediumFGButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mediumFGButtonActionPerformed(evt);
            }
        });

        hardFGButton.setMaximumSize(new java.awt.Dimension(60, 20));
        hardFGButton.setMinimumSize(new java.awt.Dimension(60, 20));
        hardFGButton.setPreferredSize(new java.awt.Dimension(60, 20));
        hardFGButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                hardFGButtonActionPerformed(evt);
            }
        });

        unfairFGButton.setMaximumSize(new java.awt.Dimension(60, 20));
        unfairFGButton.setMinimumSize(new java.awt.Dimension(60, 20));
        unfairFGButton.setPreferredSize(new java.awt.Dimension(60, 20));
        unfairFGButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                unfairFGButtonActionPerformed(evt);
            }
        });

        extremeFGButton.setMaximumSize(new java.awt.Dimension(60, 20));
        extremeFGButton.setMinimumSize(new java.awt.Dimension(60, 20));
        extremeFGButton.setPreferredSize(new java.awt.Dimension(60, 20));
        extremeFGButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                extremeFGButtonActionPerformed(evt);
            }
        });

        easyBGButton.setMaximumSize(new java.awt.Dimension(60, 20));
        easyBGButton.setMinimumSize(new java.awt.Dimension(60, 20));
        easyBGButton.setPreferredSize(new java.awt.Dimension(60, 20));
        easyBGButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                easyBGButtonActionPerformed(evt);
            }
        });

        mediumBGButton.setMaximumSize(new java.awt.Dimension(60, 20));
        mediumBGButton.setMinimumSize(new java.awt.Dimension(60, 20));
        mediumBGButton.setPreferredSize(new java.awt.Dimension(60, 20));
        mediumBGButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mediumBGButtonActionPerformed(evt);
            }
        });

        hardBGButton.setMaximumSize(new java.awt.Dimension(60, 20));
        hardBGButton.setMinimumSize(new java.awt.Dimension(60, 20));
        hardBGButton.setPreferredSize(new java.awt.Dimension(60, 20));
        hardBGButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                hardBGButtonActionPerformed(evt);
            }
        });

        unfairBGButton.setMaximumSize(new java.awt.Dimension(60, 20));
        unfairBGButton.setMinimumSize(new java.awt.Dimension(60, 20));
        unfairBGButton.setPreferredSize(new java.awt.Dimension(60, 20));
        unfairBGButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                unfairBGButtonActionPerformed(evt);
            }
        });

        extremeBGButton.setMaximumSize(new java.awt.Dimension(60, 20));
        extremeBGButton.setMinimumSize(new java.awt.Dimension(60, 20));
        extremeBGButton.setPreferredSize(new java.awt.Dimension(60, 20));
        extremeBGButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                extremeBGButtonActionPerformed(evt);
            }
        });

        incompleteLabel.setText("jLabel1"); // NOI18N

        incompleteFGButton.setMaximumSize(new java.awt.Dimension(60, 20));
        incompleteFGButton.setMinimumSize(new java.awt.Dimension(60, 20));
        incompleteFGButton.setPreferredSize(new java.awt.Dimension(60, 20));
        incompleteFGButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                incompleteFGButtonActionPerformed(evt);
            }
        });

        jTextField1.setEditable(false);

        incompleteBGButton.setMaximumSize(new java.awt.Dimension(60, 20));
        incompleteBGButton.setMinimumSize(new java.awt.Dimension(60, 20));
        incompleteBGButton.setPreferredSize(new java.awt.Dimension(60, 20));
        incompleteBGButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                incompleteBGButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(easyLabel)
                    .addComponent(mediumLabel)
                    .addComponent(hardLabel)
                    .addComponent(unfairLabel)
                    .addComponent(extremeLabel)
                    .addComponent(incompleteLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(unfairTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(unfairFGButton, 0, 0, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(hardTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(hardFGButton, 0, 0, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(mediumTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(mediumFGButton, 0, 0, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(easyTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(easyFGButton, javax.swing.GroupLayout.PREFERRED_SIZE, 25, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(extremeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(incompleteFGButton, javax.swing.GroupLayout.PREFERRED_SIZE, 25, Short.MAX_VALUE)
                            .addComponent(extremeFGButton, 0, 0, Short.MAX_VALUE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(extremeBGButton, 0, 25, Short.MAX_VALUE)
                    .addComponent(unfairBGButton, 0, 25, Short.MAX_VALUE)
                    .addComponent(hardBGButton, 0, 25, Short.MAX_VALUE)
                    .addComponent(mediumBGButton, 0, 25, Short.MAX_VALUE)
                    .addComponent(easyBGButton, javax.swing.GroupLayout.PREFERRED_SIZE, 25, Short.MAX_VALUE)
                    .addComponent(incompleteBGButton, javax.swing.GroupLayout.PREFERRED_SIZE, 25, Short.MAX_VALUE))
                .addGap(42, 42, 42))
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {easyTextField, extremeTextField, hardTextField, jTextField1, mediumTextField, unfairTextField});

        jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {easyBGButton, extremeFGButton, hardFGButton, mediumFGButton, unfairFGButton});

        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(easyLabel)
                            .addComponent(easyTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(easyFGButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(mediumLabel)
                            .addComponent(mediumTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(mediumFGButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(hardLabel)
                            .addComponent(hardTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(hardFGButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(unfairLabel)
                            .addComponent(unfairTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(unfairFGButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(extremeLabel)
                            .addComponent(extremeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(extremeFGButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(easyBGButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(mediumBGButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(hardBGButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(unfairBGButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(extremeBGButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(incompleteFGButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(incompleteLabel)
                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(incompleteBGButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(49, Short.MAX_VALUE))
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {easyBGButton, easyFGButton, easyTextField, extremeBGButton, extremeFGButton, extremeTextField, hardBGButton, hardFGButton, hardTextField, incompleteBGButton, incompleteFGButton, jTextField1, mediumBGButton, mediumFGButton, mediumTextField, unfairBGButton, unfairFGButton, unfairTextField});

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(bundle.getString("ConfigLevelFontPanel.jPanel3.border.title_1"))); // NOI18N

        valuesLabel.setText(bundle.getString("ConfigLevelFontPanel.valuesLabel.text_1")); // NOI18N

        candidatesLabel.setText(bundle.getString("ConfigLevelFontPanel.candidatesLabel.text_1")); // NOI18N

        printLargeLabel.setText(bundle.getString("ConfigLevelFontPanel.printLargeLabel.text_1")); // NOI18N

        printSmallLabel.setText(bundle.getString("ConfigLevelFontPanel.printSmallLabel.text_1")); // NOI18N

        valuesFontLabel.setText("jLabel1"); // NOI18N

        candidatesFontLabel.setText("jLabel2"); // NOI18N

        printLargeFontLabel.setText("jLabel3"); // NOI18N

        printSmallFontLabel.setText("jLabel4"); // NOI18N

        valuesButton.setText("..."); // NOI18N
        valuesButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                valuesButtonActionPerformed(evt);
            }
        });

        candidatesButton.setText("..."); // NOI18N
        candidatesButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                candidatesButtonActionPerformed(evt);
            }
        });

        printLargeButton.setText("..."); // NOI18N
        printLargeButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                printLargeButtonActionPerformed(evt);
            }
        });

        printSmallButton.setText("..."); // NOI18N
        printSmallButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                printSmallButtonActionPerformed(evt);
            }
        });

        valueFactorLabel.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("intl/ConfigLevelFontPanel").getString("ConfigLevelFontPanel.valueFactorLabel.mnemonic").charAt(0));
        valueFactorLabel.setLabelFor(valueFactorTextField);
        valueFactorLabel.setText(bundle.getString("ConfigLevelFontPanel.valueFactorLabel.text_1")); // NOI18N

        candidatesFactorLabel.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("intl/ConfigLevelFontPanel").getString("ConfigLevelFontPanel.candidatesFactorLabel.mnemonic").charAt(0));
        candidatesFactorLabel.setLabelFor(candidateFactorTextField);
        candidatesFactorLabel.setText(bundle.getString("ConfigLevelFontPanel.candidatesFactorLabel.text_1")); // NOI18N

        hintFactorLabel.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("intl/ConfigLevelFontPanel").getString("ConfigLevelFontPanel.hintFactorLabel.mnemonic").charAt(0));
        hintFactorLabel.setLabelFor(hintFactorTextField);
        hintFactorLabel.setText(bundle.getString("ConfigLevelFontPanel.hintFactorLabel.text_1")); // NOI18N

        boxFactorLabel.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("intl/ConfigLevelFontPanel").getString("ConfigLevelFontPanel.boxFactorLabel.mnemonic").charAt(0));
        boxFactorLabel.setLabelFor(boxFactorTextField);
        boxFactorLabel.setText(bundle.getString("ConfigLevelFontPanel.boxFactorLabel.text")); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(valuesLabel)
                            .addComponent(candidatesLabel)
                            .addComponent(printLargeLabel)
                            .addComponent(printSmallLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(printSmallFontLabel)
                            .addComponent(printLargeFontLabel)
                            .addComponent(candidatesFontLabel)
                            .addComponent(valuesFontLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(valuesButton)
                            .addComponent(candidatesButton)
                            .addComponent(printLargeButton)
                            .addComponent(printSmallButton)))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(valueFactorLabel)
                            .addComponent(candidatesFactorLabel)
                            .addComponent(hintFactorLabel)
                            .addComponent(boxFactorLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(boxFactorTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(hintFactorTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(candidateFactorTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(valueFactorTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(33, Short.MAX_VALUE))
        );

        jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {boxFactorTextField, candidateFactorTextField, hintFactorTextField, valueFactorTextField});

        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(valuesLabel)
                    .addComponent(valuesFontLabel)
                    .addComponent(valuesButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(candidatesLabel)
                    .addComponent(candidatesFontLabel)
                    .addComponent(candidatesButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(printLargeLabel)
                    .addComponent(printLargeFontLabel)
                    .addComponent(printLargeButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(printSmallLabel)
                    .addComponent(printSmallFontLabel)
                    .addComponent(printSmallButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(valueFactorLabel)
                    .addComponent(valueFactorTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(candidatesFactorLabel)
                    .addComponent(candidateFactorTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(hintFactorLabel)
                    .addComponent(hintFactorTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(boxFactorLabel)
                    .addComponent(boxFactorTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        resetButton.setMnemonic(java.util.ResourceBundle.getBundle("intl/ConfigLevelFontPanel").getString("ConfigLevelFontPanel.resetButton.mnemonic").charAt(0));
        resetButton.setText(bundle.getString("ConfigLevelFontPanel.resetButton.text_1")); // NOI18N
        resetButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                resetButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 343, Short.MAX_VALUE)
                        .addComponent(resetButton)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 97, Short.MAX_VALUE)
                        .addComponent(resetButton)))
                .addContainerGap())
        );

        layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jPanel1, jPanel3});

    }// </editor-fold>//GEN-END:initComponents

    private void resetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resetButtonActionPerformed
        initAll(true);
    }//GEN-LAST:event_resetButtonActionPerformed

    private void printSmallButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_printSmallButtonActionPerformed
        chooseFont(3);
    }//GEN-LAST:event_printSmallButtonActionPerformed

    private void printLargeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_printLargeButtonActionPerformed
        chooseFont(2);
    }//GEN-LAST:event_printLargeButtonActionPerformed

    private void candidatesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_candidatesButtonActionPerformed
        chooseFont(1);
    }//GEN-LAST:event_candidatesButtonActionPerformed

    private void valuesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_valuesButtonActionPerformed
        chooseFont(0);
    }//GEN-LAST:event_valuesButtonActionPerformed

    private void incompleteBGButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_incompleteBGButtonActionPerformed
        chooseColor(0, false);
    }//GEN-LAST:event_incompleteBGButtonActionPerformed

    private void incompleteFGButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_incompleteFGButtonActionPerformed
        chooseColor(0, true);
    }//GEN-LAST:event_incompleteFGButtonActionPerformed

    private void extremeBGButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_extremeBGButtonActionPerformed
        chooseColor(5, false);
    }//GEN-LAST:event_extremeBGButtonActionPerformed

    private void extremeFGButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_extremeFGButtonActionPerformed
        chooseColor(5, true);
    }//GEN-LAST:event_extremeFGButtonActionPerformed

    private void unfairBGButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_unfairBGButtonActionPerformed
        chooseColor(4, false);
    }//GEN-LAST:event_unfairBGButtonActionPerformed

    private void unfairFGButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_unfairFGButtonActionPerformed
        chooseColor(4, true);
    }//GEN-LAST:event_unfairFGButtonActionPerformed

    private void hardBGButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hardBGButtonActionPerformed
        chooseColor(3, false);
    }//GEN-LAST:event_hardBGButtonActionPerformed

    private void hardFGButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hardFGButtonActionPerformed
        chooseColor(3, true);
    }//GEN-LAST:event_hardFGButtonActionPerformed

    private void mediumBGButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mediumBGButtonActionPerformed
        chooseColor(2, false);
    }//GEN-LAST:event_mediumBGButtonActionPerformed

    private void mediumFGButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mediumFGButtonActionPerformed
        chooseColor(2, true);
    }//GEN-LAST:event_mediumFGButtonActionPerformed

    private void easyBGButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_easyBGButtonActionPerformed
        chooseColor(1, false);
    }//GEN-LAST:event_easyBGButtonActionPerformed

    private void easyFGButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_easyFGButtonActionPerformed
        chooseColor(1, true);
    }//GEN-LAST:event_easyFGButtonActionPerformed
    
    public void okPressed() {
        // levels[0] = INCOMPLETE
        int[] oldScores = new int[levels.length];
        for (int i = 1; i < levels.length; i++) {
            oldScores[i] = levels[i].getMaxScore();
        }
        levels[1].setMaxScore(Integer.parseInt(easyTextField.getText()));
        levels[2].setMaxScore(Integer.parseInt(mediumTextField.getText()));
        levels[3].setMaxScore(Integer.parseInt(hardTextField.getText()));
        levels[4].setMaxScore(Integer.parseInt(unfairTextField.getText()));
        Options.getInstance().setDifficultyLevels(Options.getInstance().copyDifficultyLevels(levels));
        // now check, if the scores have changed
        boolean scoresChanged = false;
        for (int i = 1; i < levels.length; i++) {
            if (levels[i].getMaxScore() != oldScores[i]) {
                scoresChanged = true;
                break;
            }
        }
        if (scoresChanged) {
            BackgroundGeneratorThread.getInstance().resetAll();
        }
        
        Options.getInstance().setDefaultValueFont(fonts[0]);
        Options.getInstance().setDefaultCandidateFont(fonts[1]);
        Options.getInstance().setBigFont(fonts[2]);
        Options.getInstance().setSmallFont(fonts[3]);
        
        try {
            Options.getInstance().setValueFontFactor(Double.parseDouble(valueFactorTextField.getText()));
        } catch (NumberFormatException ex) {
            Options.getInstance().setValueFontFactor(Options.VALUE_FONT_FACTOR);
        }
        try {
            Options.getInstance().setCandidateFontFactor(Double.parseDouble(candidateFactorTextField.getText()));
        } catch (NumberFormatException ex) {
            Options.getInstance().setCandidateFontFactor(Options.CANDIDATE_FONT_FACTOR);
        }
        try {
            Options.getInstance().setHintBackFactor(Double.parseDouble(hintFactorTextField.getText()));
        } catch (NumberFormatException ex) {
            Options.getInstance().setHintBackFactor(Options.HINT_BACK_FACTOR);
        }
        try {
            Options.getInstance().setBoxLineFactor(Double.parseDouble(boxFactorTextField.getText()));
        } catch (NumberFormatException ex) {
            Options.getInstance().setBoxLineFactor(Options.BOX_LINE_FACTOR);
        }
    }
    
    private void initAll(boolean setDefault) {
        if (setDefault) {
            levels = Options.getInstance().copyDifficultyLevels(Options.DEFAULT_DIFFICULTY_LEVELS);

            fonts[0] = Options.DEFAULT_VALUE_FONT;
            fonts[1] = Options.DEFAULT_CANDIDATE_FONT;
            fonts[2] = Options.BIG_FONT;
            fonts[3] = Options.SMALL_FONT;
            
            valueFactor = Options.VALUE_FONT_FACTOR;
            candidateFactor = Options.CANDIDATE_FONT_FACTOR;
            hintFactor = Options.HINT_BACK_FACTOR;
            boxFactor = Options.BOX_LINE_FACTOR;
        } else {
            levels = Options.getInstance().copyDifficultyLevels(Options.getInstance().getDifficultyLevels());
            
            fonts[0] = Options.getInstance().getDefaultValueFont();
            fonts[1] = Options.getInstance().getDefaultCandidateFont();
            fonts[2] = Options.getInstance().getBigFont();
            fonts[3] = Options.getInstance().getSmallFont();
            
            valueFactor = Options.getInstance().getValueFontFactor();
            candidateFactor = Options.getInstance().getCandidateFontFactor();
            hintFactor = Options.getInstance().getHintBackFactor();
            boxFactor = Options.getInstance().getBoxLineFactor();
        }
        
        initButtons();
        
        incompleteLabel.setText(levels[0].getName() + ":");
        easyLabel.setText(levels[1].getName() + ":");
        mediumLabel.setText(levels[2].getName() + ":");
        hardLabel.setText(levels[3].getName() + ":");
        unfairLabel.setText(levels[4].getName() + ":");
        extremeLabel.setText(levels[5].getName() + ":");
        
        easyTextField.setText(Integer.toString(levels[1].getMaxScore()));
        mediumTextField.setText(Integer.toString(levels[2].getMaxScore()));
        hardTextField.setText(Integer.toString(levels[3].getMaxScore()));
        unfairTextField.setText(Integer.toString(levels[4].getMaxScore()));
        
        for (int i = 0; i < fonts.length; i++) {
            setFont(fonts[i], fontLabels[i]);
        }
        
        valueFactorTextField.setText(Double.toString(valueFactor));
        candidateFactorTextField.setText(Double.toString(candidateFactor));
        hintFactorTextField.setText(Double.toString(hintFactor));
        boxFactorTextField.setText(Double.toString(boxFactor));
    }
    
    private void chooseFont(int index) {
        Font font = MyFontChooser.showDialog(null, java.util.ResourceBundle.getBundle("intl/ConfigLevelFontPanel").getString("ConfigLevelFontPanel.choose_font"), fonts[index]);
        if (font != null) {
            fonts[index] = font;
            setFont(fonts[index], fontLabels[index]);
        }
    }
    
    private void setFont(Font font, JLabel label) {
        int style = font.getStyle();
        String styleStr = "";
        switch (style) {
            case Font.PLAIN: styleStr = java.util.ResourceBundle.getBundle("intl/ConfigLevelFontPanel").getString("ConfigLevelFontPanel.regular"); break;
            case Font.BOLD: styleStr = java.util.ResourceBundle.getBundle("intl/ConfigLevelFontPanel").getString("ConfigLevelFontPanel.bold"); break;
            case Font.ITALIC: styleStr = java.util.ResourceBundle.getBundle("intl/ConfigLevelFontPanel").getString("ConfigLevelFontPanel.italic"); break;
            case Font.BOLD + Font.ITALIC: styleStr = java.util.ResourceBundle.getBundle("intl/ConfigLevelFontPanel").getString("ConfigLevelFontPanel.bold_italic"); break;
        }
        label.setText(font.getName() + " " + font.getSize() + " " + styleStr);
    }
    
    private void chooseColor(int index, boolean foreGround) {
        Color init = foreGround ? levels[index].getForegroundColor() : levels[index].getBackgroundColor();
        Color color = JColorChooser.showDialog(this, java.util.ResourceBundle.getBundle("intl/ConfigLevelFontPanel").getString("ConfigLevelFontPanel.choose_color"), init);
        if (color != null) {
            if (foreGround) {
                levels[index].setForegroundColor(color);
                initButton(levelFGButtons[index], color);
            } else {
                levels[index].setBackgroundColor(color);
                initButton(levelBGButtons[index], color);
            }
        }
    }
    
    private void initButtons() {
        for (int i = 0; i < levelFGButtons.length; i++) {
            initButton(levelFGButtons[i], levels[i].getForegroundColor());
            initButton(levelBGButtons[i], levels[i].getBackgroundColor());
        }
    }
    
    private void initButton(JButton button, Color color) {
        Image img = new BufferedImage(10, 10, BufferedImage.TYPE_INT_RGB);
        Graphics g = img.getGraphics();
        g.setColor(color);
        g.fillRect(0, 0, 10, 10);
        button.setIcon(new ImageIcon(img));
        if (UIManager.getLookAndFeel().getName().equals("CDE/Motif")) {
            button.setBackground(color);
        }
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel boxFactorLabel;
    private javax.swing.JTextField boxFactorTextField;
    private javax.swing.JTextField candidateFactorTextField;
    private javax.swing.JButton candidatesButton;
    private javax.swing.JLabel candidatesFactorLabel;
    private javax.swing.JLabel candidatesFontLabel;
    private javax.swing.JLabel candidatesLabel;
    private javax.swing.JButton easyBGButton;
    private javax.swing.JButton easyFGButton;
    private javax.swing.JLabel easyLabel;
    private javax.swing.JTextField easyTextField;
    private javax.swing.JButton extremeBGButton;
    private javax.swing.JButton extremeFGButton;
    private javax.swing.JLabel extremeLabel;
    private javax.swing.JTextField extremeTextField;
    private javax.swing.JButton hardBGButton;
    private javax.swing.JButton hardFGButton;
    private javax.swing.JLabel hardLabel;
    private javax.swing.JTextField hardTextField;
    private javax.swing.JLabel hintFactorLabel;
    private javax.swing.JTextField hintFactorTextField;
    private javax.swing.JButton incompleteBGButton;
    private javax.swing.JButton incompleteFGButton;
    private javax.swing.JLabel incompleteLabel;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JButton mediumBGButton;
    private javax.swing.JButton mediumFGButton;
    private javax.swing.JLabel mediumLabel;
    private javax.swing.JTextField mediumTextField;
    private javax.swing.JButton printLargeButton;
    private javax.swing.JLabel printLargeFontLabel;
    private javax.swing.JLabel printLargeLabel;
    private javax.swing.JButton printSmallButton;
    private javax.swing.JLabel printSmallFontLabel;
    private javax.swing.JLabel printSmallLabel;
    private javax.swing.JButton resetButton;
    private javax.swing.JButton unfairBGButton;
    private javax.swing.JButton unfairFGButton;
    private javax.swing.JLabel unfairLabel;
    private javax.swing.JTextField unfairTextField;
    private javax.swing.JLabel valueFactorLabel;
    private javax.swing.JTextField valueFactorTextField;
    private javax.swing.JButton valuesButton;
    private javax.swing.JLabel valuesFontLabel;
    private javax.swing.JLabel valuesLabel;
    // End of variables declaration//GEN-END:variables
    
    public static void main(String[] args) {
        
        Locale oldDefault = Locale.getDefault();
        Locale.setDefault(Locale.ENGLISH);
        List<String> availableLanguages = new ArrayList<String>();
        List<Locale> availableLocales = new ArrayList<Locale>();
        String[] isoLanguages = Locale.getISOLanguages();
        for (String isoLang : isoLanguages) {
            Locale locale = new Locale(isoLang);
            String lang = locale.getDisplayLanguage();
            System.out.println("Locale: " + locale.toString() + " (" + lang + ")");
            ResourceBundle bundle = ResourceBundle.getBundle("intl/MainFrame", locale);
            System.out.println("  Returned: " + bundle.getLocale().toString() + " (" + bundle.getLocale().getDisplayLanguage() + " - " + bundle.getString("MainFrame.error") + ")");
            if (bundle.getLocale().getLanguage().equals(isoLang)) {
                availableLanguages.add(locale.getDisplayLanguage());
                availableLocales.add(locale);
                System.out.println("  ADDED");
            }
        }
        System.out.println();
        System.out.println("Sprachen:");
        for (int i = 0; i < availableLanguages.size(); i++) {
            String la = availableLanguages.get(i);
            Locale lo = availableLocales.get(i);
            System.out.println("  " + la + " (" + lo + ")");
        }
        Locale.setDefault(oldDefault);
    }
}
    
